Solution is still bad but I really don't see myself being able to program any of the better ideas I have. (I don't like prod, but it's obvious why this puzzle has to be prod.)